package vg.services.user_interface_manager.additional_swing_components;

import java.awt.Component;

import javax.swing.JLabel;
import javax.swing.JTable;
import javax.swing.table.TableCellRenderer;

/**
 * This class is implement cell renderer for table with multiline tooltip.
 * @author dkolbin
 */
public class TableCellTooltipRender extends JLabel implements TableCellRenderer {

	/**
	 * 
	 */
	private static final long serialVersionUID = 8311335729742858404L;

	public Component getTableCellRendererComponent(JTable table, Object value,
			boolean isSelected, boolean hasFocus, int row, int column) {
		String str = (String) value;
		
		setText(str);
		setToolTipText("<html>" + str.replaceAll("\\n", "<br>") + "</html>");		
		return this;
	}

}
